<template>
	<view class="wrap">
		<ErrDialog v-if="errDialogOpen" ref="errDialog" :dialogData="dialogData" @retryFunciton="retryFunciton">
		</ErrDialog>
		<!-- <PdaScan></PdaScan> -->
		<!-- :is-scroll="true" -->
		<u-tabs :list="list" :current="current" @change="change"></u-tabs>
		<!-- 当前套餐 -->
		<view v-if="current === 0" style="padding-bottom: 140rpx;">
			<view class="example-body">
				<!-- <u-form-item label="库房" label-width="170">
					<uni-data-select placeholder="请选择库房" v-model="form.kuf_no" :localdata="kufList"
						@showSelector="showSelector($event)" @change="changeKuf"></uni-data-select>
				</u-form-item>
				<u-form-item label="区域" label-width="170">
					<uni-data-select placeholder="请选择区域" :disabled="notChangeQuyNo" v-model="form.quy_no"
						@showSelector="showSelector($event)" :localdata="quNoList"
						@change="changeQuyNo"></uni-data-select>
				</u-form-item> -->

				<u-form-item label="工作站" label-width="170">

					<uni-data-select placeholder="请选择工作站" v-model="GZTID" @showSelector="showSelector($event)"
						:localdata="gztList" @change="changeGzt"></uni-data-select>

				</u-form-item>
				<!-- <u-form-item label="" label-width="170" right-icon="arrow-right">
					<u-button shape="square" type="primary" size="medium" @click="searchHz">查询</u-button>

				</u-form-item> -->
				<!-- <u-form-item label="单据列表" label-width="170" right-icon="arrow-right">
					<u-input placeholder="去列表选择" type="button" @click="navTo('/pages/sys/storage/list')"
						class="form-field-select" />
				</u-form-item> -->
				<!-- <u-form-item label="托盘号" label-width="170" right-icon="">
					<u-input v-model="tpbar" placeholder="请输入托盘号或扫码" style="width: 80%;" />

				</u-form-item> -->
				<!-- <u-gap height="20" bg-color="#f5f5f5"></u-gap> -->
				<!-- <view v-show="hzList.length<1" style="margin: 460rpx;"></view> -->
				<view v-show="showHeight" style="margin: 460rpx;"></view>
			</view>
			<!-- <view class="search">
				<u-search input-align="center" height="70" v-model="goods" placeholder="请输入商品信息"
					@custom='searchHz'></u-search>
			</view> -->
			<u-empty v-if="!hzList.length" text="无明细数据,请尝试不同的搜索条件进行搜索" mode="page"></u-empty>

			<u-card v-for="(item, index) in hzList" class="task-list-item" :border="false" padding="20" margin="20rpx"
				@click="goTo(item,index)">
				<view slot="head" style="display: flex;align-items: center;justify-content: space-between;">
					<view style="display: flex;align-items: center;font-size: 30rpx;">
						<!-- <image class="user-images" src="/static/aidex/images/user06.png"></image> -->
						{{index+1}}.货位：{{item.LOCATION}}
					</view>
					<view style="color: #999999;font-size: 22rpx;">{{item.KUF_NO}}</view>
				</view>
				<view class="" slot="body">
					<u-row gutter="16">
						<!-- <u-col span="12">
							<view class="apply-text"><span>托盘号：</span>{{item.TPBAR}}</view>
						</u-col> -->
						<!-- <u-col span="12">
							<view class="apply-text"><span>库别：</span>{{item.KUB}}</view>
						</u-col>
						<u-col span="12">
							<view class="apply-text"><span>库房：</span>{{item.KUF_NO}}</view>
						</u-col> -->
						<u-col span="12">
							<view class="apply-text"><span>区域：</span>{{item.QUY_NO}}</view>
						</u-col>
						<u-col span="12">
							<view class="apply-text"><span>货位：</span>{{item.LOCATION}}</view>
						</u-col>
						<!-- <u-col span="12">
							<view class="apply-text"><span>货架面：</span>{{item.QUY_NO}}</view>
						</u-col> -->
					</u-row>
				</view>
				<!-- <view class="apply-list-foot" slot="foot" :style="overStyle(item.over)">
					{{item.over? "入库完成":"未入库"}}
				</view> -->

			</u-card>
			<u-loadmore :status="status" />
			<u-row gutter="32" class="more-bottom-box" justify="center">
				<!-- <u-col span="10">
					<view>
						<u-button class="more-button" type="" shape="circle" @click="scan1('tpbar')">扫托盘号</u-button>
					</view>
				</u-col> -->
				<u-col span="10">
					<view>
						<u-button class="more-button" type="primary" shape="circle" @click="searchHz">搜索</u-button>
					</view>
				</u-col>

				<!-- <u-col span="10">
					<view><u-button class="more-button" type="primary" shape="circle" @click="submitIn">下架</u-button>
					</view>
				</u-col> -->

			</u-row>
		</view>
		<view v-if="current === 1" class="example-body" style="padding-bottom: 140rpx;">
			<!-- 	<u-radio-group v-model="value" @change="radioGroupChange">
						<u-radio
							@change="radioChange"
							v-for="(item, index) in radioList" :key="index"
							:name="item.name"
							:disabled="item.disabled"
						>
							{{item.name}}
						</u-radio> -->
			<!-- 给第一个为默认值 -->
			<u-empty v-if="!huojGoodsList.length" text="请选择一条汇总信息" mode="page"></u-empty>
			{{selectedMx}}
			<u-checkbox-group v-model="SEQNO" @change="radioGroupChange">
				<u-card v-for="(item, index) in huojGoodsList" class="task-list-item" :border="false" padding="20"
					margin="20rpx">
					<view slot="head" style="display: flex;align-items: center;justify-content: space-between;">
						<view style="display: flex;align-items: center;font-size: 30rpx;">
							<!-- <image class="user-images" src="/static/aidex/images/user06.png"></image> -->
							{{index+1}}.{{item.GDNAME}}
						</view>
						<view style="color: #999999;font-size: 22rpx;">{{item.BATCHNO}}</view>
					</view>
					<view class="" slot="body">
						<u-row gutter="16">
							<!-- <u-col span="12">
							<view class="apply-text"><span>托盘号：</span>{{item.TPBAR}}</view>
						</u-col> -->
							<!-- <u-col span="12">
							<view class="apply-text">
								<u-row>
									<uni-col :span="8">
										<span>显示货位：</span>
									</uni-col>
									<uni-col :span="16">
										{{item.LOCATION}}
									</uni-col>
									</u-row>
								</view>
						</u-col> -->
							<!-- <u-col span="12">
							<view class="apply-text">
								<u-row>
									<uni-col :span="8">
										<span>显示货位：</span>
									</uni-col>
									<uni-col :span="16">
										{{item.LOCATION}}
									</uni-col>
									</u-row>
								</view>
						</u-col> -->
							<u-col span="12">
								<view class="apply-text"><span>显示货位：</span>{{item.LOCATION}}</view>
							</u-col>

							<u-col span="12">
								<view class="apply-text"><span>业主名称：</span>{{item.YEZ_NAME}}</view>
							</u-col>
							<u-col span="12">
								<view class="apply-text"><span>上游编码：</span>{{item.GDSEQ}}</view>
							</u-col>
							<u-col span="12">
								<view class="apply-text"><span>商品名称：</span>{{item.GDNAME}}</view>
							</u-col>
							<u-col span="12">
								<view class="apply-text"><span>商品规格：</span>{{item.GDSPEC}}</view>
							</u-col>
							<u-col span="12">
								<view class="apply-text"><span>生产厂家：</span>{{item.PRODUCERNAME}}</view>
							</u-col>
							<!-- <u-col span="12">
								<view class="apply-text"><span>批次ID：</span>{{item.ITEMID}}</view>
							</u-col> -->
							<u-col span="12">
								<view class="apply-text"><span>批号：</span>{{item.BATCHNO}}</view>
							</u-col>
							<u-col span="12">
								<view class="apply-text"><span>效期：</span>{{item.EFFDATE}}</view>
							</u-col>
							<u-col span="12">
								<view class="apply-text"><span>生产日期：</span>{{item.PRODUCTDATE}}</view>
							</u-col>
							<!-- <u-col span="12">
								<view class="apply-text"><span>托盘条码：</span>{{item.TPBAR}}</view>
							</u-col> -->
							<!-- <u-col span="12">
								<view class="apply-text"><span>唯一码：</span>{{item.UNIQUECODE}}</view>
							</u-col> -->
							<!-- <u-col span="12">
								<view class="apply-text"><span>唯一码：</span>{{item.LOCATION}}</view>
							</u-col> -->

							<u-col span="12">
								<view class="apply-text"><span>包装数量：</span>{{item.NUM_DABZ}}</view>
							</u-col>
							<!-- <u-col span="12">
								<view class="apply-text"><span>整件数量：</span>0</view>
							</u-col> -->
							<u-col span="12">
								<view class="apply-text"><span>系统数量：</span>{{item.SHIP_AMOUNT}}</view>
							</u-col>
							<u-col span="12">
								<u-form-item label="库存数量" label-width="140">
									<uni-easyinput v-model="item.SHIP_AMOUNT"></uni-easyinput>
								</u-form-item>
							</u-col>


							<u-divider color="#fa3534" half-width="400"></u-divider>


							<!-- 	<u-radio @change="radioChange" :name="index" :disabled="item.disabled">
								选择此条提交
							</u-radio> -->

							<u-checkbox @change="radioChange" v-model="item.checked" :key="index"
								:name="item.PDNO+'@'+item.SORTSN">
								选择此条数据</u-checkbox>

							<!-- <uni-data-checkbox style="padding-left: 200rpx;"
						v-model="baseFormData.sex" :localdata="only_one" /> -->
						</u-row>
					</view>
					<!-- <view class="apply-list-foot" slot="foot" :style="overStyle(item.over)">
					{{item.over? "入库完成":"未入库"}}
				</view> -->

				</u-card>

			</u-checkbox-group>
		</view>
		<u-row v-if="current === 1" gutter="32" class="more-bottom-box" justify="center">
			<u-col span="10">
				<view><u-button :disabled="!huojGoodsList.length" class="more-button" type="primary" shape="circle"
						@click="submitCheckAll('returnSearch')">提交并返回货位列表</u-button>
				</view>
			</u-col>
			<u-col span="10">
				<view><u-button :disabled="!huojGoodsList.length" class="more-button" type="primary" shape="circle"
						@click="submitCheckAll()">提交</u-button>
				</view>
			</u-col>
		</u-row>
		<view v-if="current === 2" style="padding-bottom: 120rpx;">


			<u-form :model="form">

				test

			</u-form>
			<u-row gutter="32" class="more-bottom-box" justify="center">
				<u-col span="10">
					<view>
						<u-button class="more-button" type="primary" shape="circle"
							@click="scan1('tpbar')">扫入库单</u-button>
					</view>
				</u-col>
				<u-col span="10">
					<view><u-button class="more-button" type="primary" shape="circle" @click="submitIn">下架</u-button>
					</view>
				</u-col>

			</u-row>
		</view>
	</view>
</template>
<script>
	import ErrDialog from '@/components/err-dialog.vue'
	export default {
		components: {
			ErrDialog
		},

		data() {
			return {
				showHeight: false,
				notChangeQuyNo: true,
				form: {
					kuf_no: '',
					quy_no: '',
					gztid: '',
					tpNum: '1',
					//1：空托入库2：空托出库
					czlx: '1',
					landpoint: 'DHJ01',
					tpbar: ''
				},
				errDialogOpen: false,
				// 提示信息
				dialogData: {
					title: '出库',
					msgType: '',
					errContent: '',
					confirmText: '',
					functionName: '',
					cancelText: '',
					closeFunction: '',
				},
				//是否为正常物料
				ISZCGD: '',
				keywords: '',
				form: {
					huoz_id: '',
					tpbar: '',
					itm: '',
					rwid: '',
				},
				border: true,
				show: false,
				//库房展示
				kufShow: false,

				// 工作台下拉展示
				gzzShow: false,
				// 当前工作台中文
				gztNowLabel: '',
				GZTID: '',
				tips: '工作站选择',

				// 被选中的商品明细下标
				selectItemIndex: '',
				selectedMx: [],
				// 托盘的商品明细
				// huojGoodsList: [],
				// 货架上的货位商品明细
				huojGoodsList: [],

				demo_amount: '',

				//选中的明细
				SEQNO: '',
				// 选中的货架号
				HUOJNO: '',
				//选中的货架面
				ORIENTATIONS: '',
				//当前选中的托盘号
				tpbar: '',
				kuf: '',
				// 商品相关条件
				goods: '',
				//库房
				kufList: [],
				//区域
				quNoList: [],
				//库别
				kubList: [],
				//工作台
				gztList: [],
				//日历选择显示
				calendaShow: false,
				//有效期日历显示
				calendaEffdateShow: false,
				list: [{
					name: '明细筛选'
				}, {
					name: '明细总览',
				}],

				m2mSimflowList: [],
				m2mOrderFlowList: [],
				current: 0,
				result1: '',
				status: 'nomore',
				iconType: 'circle',
				isDot: false,
				loadText: {
					loadmore: '点击加载更多',
					loading: '正在加载...',
					nomore: '没有更多了'
				},
				// 搜索栏的托盘号
				tpbar: '',
				nvueWidth: 730,
				only_one: [{
					text: '选择此项',
					value: 0
				}],
				// 基础表单数据
				baseFormData: {
					name: '',
					age: '',
					introduction: '',
					sex: 2,
					hobby: [5],
					datetimesingle: 1627529992399
				},
				// 汇总信息存储
				hzData: {

				},
				// 点击的汇总下标
				hzIndex: '',
				refreshInHead: true,
				refreshMxMsg: true,
				hzList: [],

				oneMx: {},
				disableTrue: true,
				// 入库点
				landpoint: '',
				sjAmouont: '1',
				sjLocation: '',
			}
		},
		// 该写提交盘点单了 接口7

		onLoad(option) {
			// this.form.kuf_no = uni.getStorageSync("inventory-check-kuf_no")
			// this.getKufbyKuf()
			// setTimeout(() => {
			// 	this.form.quy_no = uni.getStorageSync("inventory-check-quy_no")

			// }, 1000)
			// this.form.tpNum=uni.getStorageSync("inventory-check-landpoint")

			// if (option) {
			// 	if (option.item) {
			// 		let item = JSON.parse(option.item)
			// 		this.hzData = item
			// 		console.log('收到的:' + JSON.stringify(item))
			// 		console.log('收到的:' + item.INPAGENO)
			// 		this.tpbar = item.INPAGENO;
			// 		this.getInListOneInfo()
			// 	}
			// }
		},

		created() {
			// this.getKuf(2)
			// this.getKuf(3)
			this.getGzt()
			this.init()

			this.searchHz()
		},
		// 数据变化适用
		onShow() {
			this.myShow()

		},
		onBackPress() {
			console.log("点击了返回")
			uni.switchTab({
				url: "/pages/sys/workbench/wms-work"
			})
			return true
		},
		methods: {
			// 选中某个单选框时，由radio时触发
			radioChange(e) {
				console.log(e);
				this.selectItemIndex = e
			},
			// 选中任一radio时，由radio-group触发
			radioGroupChange(evt) {
				this.selectedMx = evt
				console.log(evt);
				// if (this.huojList) {
				// 	this.huojListCenter = this.huojList.filter((item) => {
				// 		const huojAndWorkface = item.HUOJNO + '@' + item.ORIENTATIONS
				// 		return this.selectedMx.indexOf(huojAndWorkface) != -1
				// 	})
				// }
				// console.log("SEQNO:" + this.SEQNO)
				// console.log("radioGroupChange:" + e);
				// this.oneMx = this.huojGoodsList[e]
				// console.log("单选选择的明细:" + JSON.stringify(this.oneMx))
			},
			navTo(url) {
				// uni.navigateTo({
				// 	url: url
				// });
				// uni.switchTab({
				// 	url: url
				// });
				uni.switchTab({
					url: url,
					success: function(e) {
						var page = getCurrentPages().pop(); // 返回页面数组的最后一个页面数据
						if (page == undefined || page == null)
							return; //如果最后一个页面为undefined或null，即当前就在首页 return出去，不调用onLoad
						page.onLoad();
					}
				});


			},
			searchHz() {
				// this.getInListOneInfo()
				// this.getOutTpbarList()
				// this.getCheckList()
				this.getCheckList()
			},
			overStyle(over) {
				if (over) {
					return "text-align: right;color: #58ca93;";
				} else {
					return "text-align: right;color: #f28c03;";
				}
			},
			init() {
				this.GZTID = uni.getStorageSync('IN_GZTID')
				// this.kuf = uni.getStorageSync('kuf')
			},
			goTo(item, index) {
				if (item.over) {
					this.$u.toast('已完成')
					return
				} else {
					let item = this.hzList[index]
					// 如果托盘号填写了 ,则不用改,如果为空,则把选中的托盘号放进去
					// if (this.tpbar.length > 0) {

					// } else {
					// 通过点击明细,输入了入库单号,以及 预览的一些数据
					// this.tpbar = item.TPBAR
					// this.getInListBytpbar()
					// this.tpbar = item.TPBAR
					// }
					this.hzData = item
					this.hzIndex = index
					this.getLocationMxList(item)
					console.log('item:' + JSON.stringify(item))
					item.index = Number(index + 1)
					// this.oneMx = item
					// tabs转换到第一个
					this.change(1)
				}

				// let id = item.INPAGENO
				// uni.navigateTo({
				// 	url: 'index?item=' + JSON.stringify(item)
				// });
			},
			// 根据货架号和货架面获取货位数据
			// getOutInfoByTpbar() {
			// 	// 1、IV\_USER\_ID 用户编号,
			// 	// 2、IV\_HUOJNO 货架号
			// 	// 3、IV\_ORIENTATIONS 货架朝面

			// 	const USER_ID = uni.getStorageSync('USER_ID')
			// 	const GZTID = this.HUOJNO ? this.HUOJNO : "%"
			// 	const ORIENTATIONS = this.ORIENTATIONS ? this.ORIENTATIONS : "%"

			// 	let param = USER_ID + "," + GZTID + "," + ORIENTATIONS;
			// 	console.log("iv_parm:" + param)
			// 	this.$u.api.general({
			// 			iv_code: "GETSTOCKHJ",
			// 			iv_parm: param
			// 		})
			// 		.then(res => {
			// 			console.log("返回的res:" + JSON.stringify(res))
			// 			if (res.success) {
			// 				let data = res.data
			// 				console.log("返回的data:" + JSON.stringify(data))
			// 				data[0].AMOUNT = data[0].SHIP_AMOUNT

			// 				this.huojGoodsList = data.map(v => {
			// 					this.selectedMx.push(v.PDNO + '@' + v.SORTSN)
			// 					this.$set(v, 'AMOUNT', v.SHIP_AMOUNT)
			// 					this.$set(v, 'checked', true)
			// 					this.$set(v, 'disabled', false)
			// 					this.$set(v, 'value', v.PDNO + '@' + v.SORTSN)
			// 					this.$set(v, 'name', v.PDNO + '@' + v.SORTSN)
			// 					return v
			// 				})
			// 				console.log("1111111111111:"+JSON.stringify(this.huojGoodsList))

			// 				// 默认选中第一个
			// 				this.SEQNO = data[0].SEQNO
			// 				this.oneMx = data[0]
			// 				//是否新批次出库第一托
			// 				// this.isFirshOut()
			// 				// this.hzData = data[0]
			// 				// if (this.list.length < 1) {
			// 				// 	this.$u.toast("没有查到数据");
			// 				// }
			// 			} else {
			// 				this.$u.toast(res.msg);
			// 			}
			// 		});
			// },
			// // 根据托盘号,获取出库商品明细集合   返回集合后,获取到物料号后,询问第一个物料
			// getOutInfoByTpbar() {
			// 	//1、IV\_STAFF 用户id
			// 	// 2、IV\_GZTID 工作站
			// 	// 3、IV\_BARCODE 托盘号，单号

			// 	const USER_ID = uni.getStorageSync('USER_ID')
			// 	const GZTID = this.GZTID ? this.GZTID : "%"
			// 	const tpbar = this.tpbar ? this.tpbar : "%"

			// 	let param = USER_ID + "," + GZTID + "," + tpbar;
			// 	console.log("iv_parm:" + param)
			// 	this.$u.api.general({
			// 			iv_code: "PDAOUTTPBARMX",
			// 			iv_parm: param
			// 		})
			// 		.then(res => {
			// 			// console.log("返回的res:" + JSON.stringify(res))
			// 			let data = res.data
			// 			console.log("返回的data:" + JSON.stringify(data))
			// 			if (res.success) {
			// 				this.huojGoodsList = data
			// 				// 默认选中第一个
			// 				this.SEQNO = data[0].SEQNO
			// 				this.oneMx = data[0]
			// 				//是否新批次出库第一托
			// 				// this.isFirshOut()
			// 				// this.hzData = data[0]
			// 				// if (this.list.length < 1) {
			// 				// 	this.$u.toast("没有查到数据");
			// 				// }
			// 			} else {
			// 				this.$u.toast(res.msg);
			// 			}
			// 		});
			// },
			getKuf(type) {
				const USER_ID = uni.getStorageSync('USER_ID')
				const KUB = '%'
				const KUF_NO = "%"
				// if(type == "3"){
				// 	KUF_NO = this.form.kuf_no ? this.form.kuf_no : '%'
				// }
				//1获取库别，2获取库房，3获取区域
				const GET_TYPE = type
				let param = USER_ID + "," + KUB + "," + KUF_NO + "," + GET_TYPE;
				this.$u.api.general({
						iv_code: "GETKUFQUYNO",
						iv_parm: param
					})
					.then(res => {
						// console.log("返回的res:" + JSON.stringify(res))

						if (res.success) {
							let data = res.data
							console.log("kuf返回的data:" + JSON.stringify(data))
							console.log("type:" + type)
							//补充text
							// this.kufList = data
							console.log("type:" + type)
							if (type == "2") {
								this.kufList = data.map(v => {
									this.$set(v, 'text', v.KUF_NO)
									this.$set(v, 'value', v.KUF_NO)
									return v
								})
								// console.log("this.kufList:"+JSON.stringify(this.kufList))
							} else if (type == "3") {
								this.quNoList = data.map(v => {
									this.$set(v, 'text', v.QUY_NO)
									this.$set(v, 'value', v.QUY_NO)
									return v
								})
							} else {
								this.kubList = data.map(v => {
									this.$set(v, 'text', v.KUB)
									this.$set(v, 'value', v.KUB)
									return v
								})
							}

						} else {
							this.errContent = res.msg
							this.$u.toast(res.msg);
						}
					});
			},
			// 是否新批次出库第一托?
			isFirshOut() {
				// 1、IV\_STAFF 用户id
				// 2、IV\_GOODSID 商品id
				// 3、IV\_ITEMID 批次
				// 4、IV\_BATCHNO 批号
				// 5、IV\_OUT\_LX 出库场景类型
				// 6、IV\_CKJH 出库下发：1，拣货2
				const USER_ID = uni.getStorageSync('USER_ID')

				const GOODSID = this.oneMx.GOODSID ? this.oneMx.GOODSID : "%"
				const ITEMID = this.oneMx.ITEMID ? this.oneMx.ITEMID : "%"
				const BATCHNO = this.oneMx.BATCHNO ? this.oneMx.BATCHNO : "%"
				const OUT_LX = this.oneMx.OUTTYPE ? this.oneMx.OUTTYPE : "%"
				const CKJH = 2
				let param = USER_ID + "," + GOODSID + "," + ITEMID + "," +
					BATCHNO + "," + OUT_LX + "," + CKJH;
				console.log("iv_parm:" + param)
				this.$u.api.general({
						iv_code: "PDAGETFIRSTOUTFLG",
						iv_parm: param
					})
					.then(res => {
						console.log("返回的res:" + JSON.stringify(res))
						if (res.success) {
							let data = res.data
							console.log("返回的data:" + JSON.stringify(data))
							// this.hzData = data[0]
							// if (this.list.length < 1) {
							// 	this.$u.toast("没有查到数据");
							// }

							// 如果是第一次出库,进行提示
							if (data.ISFIRSTOUT == 'Y') {
								this.dialogData = {
									title: '出库检测(第一托?)',
									msgType: 'warn',
									errContent: '本明细是新批次出库第一托',
									confirmText: '继续进行出库(判断是否为正常物料)',
									// 如果选右边的执行的返回方法
									functionName: 'isNarmalGoods',
									cancelText: '关闭',
								}
								this.errDialogShow()
								this.ISZCGD = data.ISZCGD
								// if(data.ISZCGD=='Y'){
								// 	this.ISZCGD = 'Y'
								// }
							} else {
								this.submitOut()
							}

						} else {
							this.$u.toast(res.msg);
						}
					});
			},
			retryFunciton(e) {
				console.log("子组件返回的e:" + e)
				if (e == "isNarmalGoods") {
					this.isNarmalGoods()
				} else if (e == "submitCheck") {
					this.submitCheck()
				} else if (e == 'getCheckList') {
					this.getCheckList()
				}
			},
			// 是否是
			isNarmalGoods() {
				if (this.ISZCGD == 'Y') {
					// (对应PDA弹窗提醒)
					this.dialogData = {
						title: '出库检测(正常物料?)',
						msgType: 'warn',
						errContent: '本明细是正常物料',
						confirmText: '我知道了',
						// 如果选右边的执行的返回方法
						functionName: 'submitOut',
						cancelText: '关闭',
					}
					this.errDialogShow()
				} else if (this.ISZCGD == 'N') {
					// 对应pda弹窗选择确认
					this.dialogData = {
						title: '出库检测(正常物料?)',
						msgType: 'error',
						errContent: '本明细不是正常物料',
						confirmText: '同意此物料不是正常物料',
						// 如果选右边的执行的返回方法
						functionName: 'submitOut',
						cancelText: '拒绝',
						closeFunction: 'noNormalGoods',

					}
					this.errDialogShow()
				} else {
					this.$u.toast('ISZCGD未知,严重错误,请排查isFirshOut()返回值')
				}
			},
			noNormalGoods() {
				this.$u.toast('点击了否,不同意')
			},
			// // 是正常物料的弹窗提示(权限控制,指定账号弹窗)
			// isToast(){

			// },
			errDialogShow() {
				console.log("刷新显示提示框")
				//刷新显示
				let that = this;
				that.errDialogOpen = false;
				that.$nextTick(() => {
					that.errDialogOpen = true;
				})

			},
			// getInListBytpbar() {
			// 	const STORAGE_ID = uni.getStorageSync('STORAGE_ID')
			// 	const huoz_id = "%"
			// 	const USER_ID = uni.getStorageSync('USER_ID')
			// 	const inbillNumber = this.tpbar ? this.tpbar : "%"

			// 	const unit = "%"
			// 	const goodsId = "%"
			// 	const palletNumber = "%"
			// 	let param = STORAGE_ID + "," + huoz_id + "," + USER_ID + "," +
			// 		inbillNumber + "," + unit + "," + goodsId + "," + palletNumber;
			// 	console.log("iv_parm:" + param)
			// 	this.$u.api.general({
			// 			iv_code: "PDAINBILLINPAGENO",
			// 			iv_parm: param
			// 		})
			// 		.then(res => {
			// 			// console.log("返回的res:" + JSON.stringify(res))
			// 			let data = res.data
			// 			console.log("返回的data:" + JSON.stringify(data))
			// 			if (res.success) {
			// 				this.hzData = data[0]
			// 				// if (this.list.length < 1) {
			// 				// 	this.$u.toast("没有查到数据");
			// 				// }
			// 			} else {
			// 				this.$u.toast(res.msg);
			// 			}
			// 		});
			// },
			//重新加载子组件
			myShow() {

				console.log("this.hzData==>" + JSON.stringify(this.hzData))
				//刷新显示
				let that = this;
				that.refreshInHead = false;
				that.$nextTick(() => {
					that.refreshInHead = true;
				})

			},
			myMxShow() {
				//刷新显示
				let that = this;
				that.refreshMxMsg = false;
				that.$nextTick(() => {
					that.refreshMxMsg = true;
				})

			},

			scan1(param) {
				console.log("扫描")
				// #ifdef H5
				this.$u.toast('H5页面不支持扫码,请用安卓等移动设备重试')
				// #endif
				let that = this;
				// 允许从相机和相册扫码
				uni.scanCode({
					success: function(res) {
						if (param == "tpbar") {
							that.tpbar = res.result;
						} else if (param == "LOCATIONZD") {
							that.sjLocation = res.result
						}

					}
				});
			},
			change(index) {
				console.log(this.current)
				this.current = index;
			},
			submit(index) {
				if (this.tpbar) {
					this.$u.toast('调用下架接口')
				} else {
					this.$u.toast('请补充入库单号的数据')
				}
			},
			// 提交选中的明细数据
			submitCheckAll(paramReturn) {
				const selected = this.selectedMx
				if(!selected){
					this.$u.toast('请至少勾选一条要提交的盘点数据')
					return
				}
				for (let i = 0; i < selected.length; i++) {
					const pdnoAndSortsn = selected[i].split('@')
					// 筛选出来选中的所有选中数据
					const newGoodsList = this.huojGoodsList.filter((item) => {
						return item.PDNO + '@' + item.SORTSN == pdnoAndSortsn[0] + '@' + pdnoAndSortsn[1]
					})
					if (newGoodsList) {
						for (let x = 0; x < newGoodsList.length; x++) {
							const paramObject = newGoodsList[x];
							// 提交选中的
							this.submitCheck('', paramObject)

						}
					} else {
						this.$u.toast('请选中一条明细,再尝试重新提交')
					}

				}
				if (paramReturn == "returnSearch") {
					this.current = 0
				}
			},
			/**
			 * @param {Object} paramReturn 是否返回 tabs1 的页面 [明细筛选]
			 * @param {Object} paramObject 选中的数据对象
			 */
			submitCheck(paramReturn, paramObject) {

				// 1、IV\_STAFF 人员
				// 2、IV\_PDNO 盘点单号
				// 3、IN\_SORTSN 行号
				// 4、IV\_JS 件数
				// 5、IV\_LSS 零散数
				// 6、IN\_AMOUNT 实盘数量

				console.log("oneMx=>" + JSON.stringify(paramObject))
				const USER_ID = uni.getStorageSync('USER_ID')
				const PDNO = paramObject.PDNO ? paramObject.PDNO : "%"
				const SORTSN = paramObject.SORTSN ? paramObject.SORTSN : "1"
				const JS = 1
				const LSS = "0"
				const AMOUNT = paramObject.SHIP_AMOUNT ? paramObject.SHIP_AMOUNT : "0"


				let param = USER_ID + "," +
					PDNO + "," +
					SORTSN + "," +
					JS + "," +
					LSS + "," +
					AMOUNT;

				console.log("iv_parm:" + param + ";")
				let that = this
				this.$u.api.prcutlexecvar({
						iv_code: "PDRWQR",
						iv_parm: param,
						ov_var1: '2',
						ov_var2: '2',
						ov_var3: '2',
						ov_var4: '2',
						ov_var5: '2',
					})
					.then(res => {
						console.log("返回的res:" + JSON.stringify(res))
						// that.$u.toast(res.msg);
						if (res.success) {

							let data = res.data
							// console.log("返回的data:" + JSON.stringify(data))
							console.log("返回的res.msg:" + res.msg)
							this.submitSuccess()
							if (paramReturn == "returnSearch") {
								this.current = 0
							}
						} else {
							this.dialogData = {
								title: '盘点提交',
								msgType: 'error',
								errContent: res.msg,
								confirmText: '重新提交',
								// 如果选右边的执行的返回方法
								functionName: 'submitCheck',
								cancelText: '关闭',
								closeFunction: '',
							}
							this.errDialogShow()
						}

					});
			},
			// 盘点货架返回
			// submitCheck(paramReturn) {


			// 	//1、IV_GZTID 工作台
			// 	// 2、IV_BUCKETNO 货架
			// 	// 3、IV_WORKFACE 面
			// 	// 4、IV_STAFF 人员

			// 	console.log("oneMx=>" + JSON.stringify(this.oneMx))
			// 	const USER_ID = uni.getStorageSync('USER_ID')
			// 	const GZT_ID = this.GZTID
			// 	const BUCKETNO = this.oneMx.BUCKETNO?this.oneMx.BUCKETNO:''
			// 	const WORKFACE = this.oneMx.WORKFACE?this.oneMx.WORKFACE:''


			// 	const PDNO = this.oneMx.PDNO ? this.oneMx.PDNO : "%"
			// 	const SORTSN = this.oneMx.SORTSN ? this.oneMx.SORTSN : "1"
			// 	const JS = 1
			// 	const LSS = this.oneMx.AMOUNT ? this.oneMx.AMOUNT : "0"
			// 	const AMOUNT = this.oneMx.SHIP_AMOUNT ? this.oneMx.SHIP_AMOUNT : "0"


			// 	let param = USER_ID + "," +
			// 		PDNO + "," +
			// 		SORTSN + "," +
			// 		JS + "," +
			// 		LSS + "," +
			// 		AMOUNT;

			// 	console.log("iv_parm:" + param + ";")
			// 	let that = this
			// 	this.$u.api.prcutlexecvar({
			// 			iv_code: "PDHJBACK",
			// 			iv_parm: param,
			// 			ov_var1: '2',
			// 			ov_var2: '2',
			// 			ov_var3: '2',
			// 			ov_var4: '2',
			// 			ov_var5: '2',
			// 		})
			// 		.then(res => {
			// 			console.log("返回的res:" + JSON.stringify(res))
			// 			// that.$u.toast(res.msg);
			// 			if (res.success) {

			// 				let data = res.data
			// 				// console.log("返回的data:" + JSON.stringify(data))
			// 				console.log("返回的res.msg:" + res.msg)
			// 				this.submitSuccess()
			// 				if (paramReturn == "returnSearch") {
			// 					this.current = 0
			// 				}
			// 			} else {
			// 				this.dialogData = {
			// 					title: '盘点提交',
			// 					msgType: 'error',
			// 					errContent: res.msg,
			// 					confirmText: '重新提交',
			// 					// 如果选右边的执行的返回方法
			// 					functionName: 'submitCheck',
			// 					cancelText: '关闭',
			// 					closeFunction: '',
			// 				}
			// 				this.errDialogShow()
			// 			}

			// 		});
			// },

			submitOutBefore() {
				//是否新批次出库第一托
				this.isFirshOut()
			},

			// 提交成功后，刷新汇总集合，如果包含locationid 老的，
			// 那说明这个盘点单还没做完，直接获取明细，
			// 如果不包含，那么提示已经做完，并且跳转到汇总选择页面，供用户选择
			submitSuccess() {
				zhendong();
				tishiyin();
				this.removeSelected()

			},
			removeSelected(){
				this.selectedMx=[]
				this.huojGoodsList = data.map(v => {
					this.$set(v, 'checked', false)
					return v
				})
			},
			navTo(url) {
				uni.navigateTo({
					url: url
				});
			},
			// 根据货位进行搜索
			getLocationMxList(item) {

				// 1、IV\_STAFF 人员
				// 2、IV_LOCATIONID 货位
				const USER_ID = uni.getStorageSync('USER_ID')
				const locationid = item.LOCATIONID

				let param = USER_ID + "," + locationid;

				console.log("iv_parm:" + param)
				let that = this
				this.$u.api.general({
						iv_code: "GETPDHWDETAILDISP",
						iv_parm: param
					})
					.then(res => {
						console.log("返回的res:" + JSON.stringify(res))
						if (res.success) {
							let data = res.data
							console.log("返回的data:" + JSON.stringify(data))
							//补充text
							this.huojGoodsList = data
							
							this.huojGoodsList = data.map(v => {
								const ID = v.PDNO + '@' + v.SORTSN
								const result = this.selectedMx.find(item => item === ID);
								console.log("返回的result:" + JSON.stringify(result))
								if(!result){
									this.selectedMx.push(ID)
								}
								this.$set(v, 'AMOUNT', v.SHIP_AMOUNT)
								this.$set(v, 'checked', true)
								this.$set(v, 'disabled', false)
								this.$set(v, 'value', ID)
								this.$set(v, 'name', ID)
								return v
							})
							console.log("1111111111111:"+JSON.stringify(this.huojGoodsList))
							
							
							this.oneMx = this.huojGoodsList[0]

							this.status = 'nomore';
						} else {
							this.$u.toast(res.msg);
						}
					});
			},
			// 获取盘点任务列表
			getCheckList() {
				// 1、IV\_STAFF 人员
				// 2、IV\_GZTID 工作台
				// 3、IV\_STORAGEID 仓库
				// 4、IV\_KUF\_NO 库房
				// 5、IV\_QUY\_NO 区域
				const USER_ID = uni.getStorageSync('USER_ID')
				const GZTID = this.GZTID ? this.GZTID : "%"
				const STORAGE_ID = uni.getStorageSync('STORAGE_ID')
				const kuf_no = this.form.kuf_no ? this.form.kuf_no : '%'
				const quyu_no = this.form.quyu_no ? this.form.quyu_no : '%'
				let param = USER_ID + "," + GZTID + "," + STORAGE_ID +
					"," + kuf_no + "," + quyu_no;
				console.log("iv_parm:" + param)
				let that = this
				this.$u.api.general({
						iv_code: "GETPDHWDISP",
						iv_parm: param
					})
					.then(res => {
						console.log("返回的res:" + JSON.stringify(res))
						if (res.success) {
							let data = res.data
							console.log("返回的data:" + JSON.stringify(data))
							//补充text
							this.hzList = data
							if (this.hzList.length < 1) {
								this.$u.toast("暂无数据");
							}
							this.status = 'nomore';


						} else {
							this.dialogData = {
								title: '盘点汇总查询',
								msgType: 'warn',
								errContent: res.msg,
								confirmText: '重试',
								// 如果选右边的执行的返回方法
								functionName: 'getCheckList',
								cancelText: '关闭',
							}
							this.errDialogShow()
						}
					});
			},
			getOutTpbarList() {
				// 1、IV\_STAFF 用户id
				// 2、IV\_GZTID 工作站
				// 3、IV\_YEW\_TYPE业务类型2：出库
				// const STORAGE_ID = uni.getStorageSync('STORAGE_ID')
				// // const USER_GH = uni.getStorageSync('USER_GH')
				// const yez_id = this.form.huoz_id ? this.form.huoz_id : "%"
				const USER_ID = uni.getStorageSync('USER_ID')
				const GZTID = this.GZTID ? this.GZTID : "%"
				const yew_type = '2'
				let param = USER_ID + "," + GZTID + "," + yew_type;
				console.log("iv_parm:" + param)
				let that = this
				this.$u.api.general({
						iv_code: "PDAOUTTPBAR",
						iv_parm: param
					})
					.then(res => {
						// console.log("返回的res:" + JSON.stringify(res))
						let data = res.data
						// console.log("返回的data:" + JSON.stringify(data))
						if (res.success) {
							//补充text
							this.hzList = data

							this.status = 'nomore';


						} else {
							this.$u.toast(res.msg);
						}
					});
			},

			blurFunction() {
				console.log("失去了焦点")
				this.myMxShow()
			},
			changeProductDate(e) {
				console.log("选择的日期:" + JSON.stringify(e))
				this.oneMx.PRODUCTDATE = e.result
				this.myMxShow()
			},
			changeEFFDATE(e) {
				this.oneMx.EFFDATE = e.result
				this.myMxShow()
			},
			// 下拉内容是否展开
			showSelector(res) {
				console.log(res)
				this.showHeight = res
			},
			changeGzt(e) {
				this.GZTID = e
				uni.setStorageSync("IN_GZTID", e)
				console.log("盘点缓存区域号:" + uni.getStorageSync("IN_GZTID"))
				this.showHeight = false
				this.searchHz()
			},
			changeQuyNo(e) {
				this.form.quy_no = e
				uni.setStorageSync("inventory-check-quy_no", e)
				console.log("盘点缓存区域号:" + uni.getStorageSync("inventory-check-quy_no"))
				this.showHeight = false
				this.searchHz()
			},
			changeKuf(e) {
				console.log("e:" + e);
				console.log("this.kufList:" + JSON.stringify(this.kufList))
				// const item = this.kufList[e];
				// console.log("item:"+item)
				this.form.kuf_no = e
				console.log(this.form.kuf_no)
				// 判断一下区域是不是在这个库房,如果在,就不更改区域,如果不在,就更改区域
				this.getKufbyKuf()
				this.notChangeQuyNo = e ? false : true

				uni.setStorageSync("inventory-check-kuf_no", e)
				console.log("盘点缓存库房号:" + uni.getStorageSync("inventory-check-kuf_no"))
				this.showHeight = false
			},
			// 查看选择到的库房的区域
			getKufbyKuf() {
				const USER_ID = uni.getStorageSync('USER_ID')
				const KUB = '%'
				const KUF_NO = this.form.kuf_no ? this.form.kuf_no : "%"
				//1获取库别，2获取库房，3获取区域
				const GET_TYPE = 3
				let param = USER_ID + "," + KUB + "," + KUF_NO + "," + GET_TYPE;
				console.log(param)
				this.$u.api.general({
						iv_code: "GETKUFQUYNO",
						iv_parm: param
					})
					.then(res => {
						console.log("getKufbyKuf返回的res:" + JSON.stringify(res))
						let data = res.data
						console.log("查看选择到的库房的区域返回的data:" + JSON.stringify(data))
						if (res.success) {

							this.form.quy_no = uni.getStorageSync("inventory-check-quy_no")
							console.log("this.form.quy_no:" + this.form.quy_no)
							let newData = [];
							if (this.form.quy_no) {
								//补充text
								newData = data.filter((item) => {
									// 过滤如果有对象的区域参数和已经够选择的区域no相同,那么就不用覆盖已经选择的
									return item.QUY_NO === this.form.quy_no
								})
							}

							if (newData.length > 0) {
								console.log("不用重新选择,这是从对象集合种筛出来的区域号相同的对象=>" + JSON.stringify(newData))
								this.quNoList = data.map(v => {
									this.$set(v, 'text', v.QUY_NO)
									this.$set(v, 'value', v.QUY_NO)
									return v
								})
							} else {
								console.log("重新选择,这是库房对应的对象集合,=>" + JSON.stringify(data))
								this.quNoList = data.map(v => {
									this.$set(v, 'text', v.QUY_NO)
									this.$set(v, 'value', v.QUY_NO)
									return v
								})
								//如果切换的区域
								this.form.quy_no = ''
							}
							this.canChangeQuy_no()
						} else {
							this.errContent = res.msg
							this.$u.toast(res.msg);
						}
					});
			},
			// 将区域可选
			canChangeQuy_no() {
				this.notChangeQuyNo = false
			},
			getGzt(loginType) {
				const user_id = uni.getStorageSync('USER_ID')
				const STORAGE_ID = uni.getStorageSync('STORAGE_ID')
				const kuf = "%"
				const gztType = "6"
				const gztId = "%"
				let param = user_id + "," + STORAGE_ID + "," + kuf + "," + gztType + "," + gztId;
				console.log(param)
				this.$u.api.general({
						iv_code: "GETGZTINFO",
						iv_parm: param
					})
					.then(res => {
						// console.log("返回的res:" + JSON.stringify(res))
						let data = res.data
						console.log("getGzt返回的data:" + JSON.stringify(data))
						if (res.success) {
							//补充text
							this.gztList = data.map(v => {
								this.$set(v, 'text', v
									.GZTNAME + "(" + v.GZTID + ")"
								) // https://vuejs.org/v2/guide/reactivity.html
								this.$set(v, 'value', v.GZTID)
								return v
							})
							this.gztList = this.gztList.filter((item) => {
								return item.LETDOWNFLAG === 2
							})

							// 增加一条特殊的测试数据
							// this.gztList.push({
							// 	"text": "DHJ01",
							// 	"WORKLOAD": "4",
							// 	"CENG": "1",
							// 	"GZT_TYPE": "1",
							// 	"ISZCQFP": "N",
							// 	"STORAGEID": "SU3",
							// 	"WORKSTATION_TYPE": "0",
							// 	"LETDOWNFLAG": "1",
							// 	"GZTID": "DHJ01",
							// 	"GZTNAME": "DHJ01测试工作站",
							// 	"KUF_NO": "LHK"
							// })
						} else {
							this.$u.toast(res.msg);
						}
					});
			},

		}

	}
</script>
<style lang="scss" scoped>
	@import '../../common/index.scss';
	@import '../../common/base-change.scss';
</style>